<template>
  <NavBar :tokens="tokens" :user="user" />
  <router-view
    v-slot="{ Component }"
    :tokens="tokens"
    :user="user"
    @dataUpdate="
      (data) => {
        tokens = data.tokens;
        user = data.user;
      }
    "
  >
    <keep-alive :max="20">
      <component :key="$route.fullPath" :is="Component" />
    </keep-alive>
  </router-view>
</template>

<script>
import NavBar from "./components/NavBar.vue";

export default {
  name: "App",
  data() {
    let tokens = JSON.parse(localStorage.getItem("tokens"));
    let user = JSON.parse(localStorage.getItem("user"));
    return {
      tokens: tokens,
      user: user,
    };
  },
  components: {
    NavBar,
  },
};
</script>

<style>
</style>
